package edu.kit.csl.cratylus.datatypes;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

/**
 * A corpus is modeled as set of SentencePair instances. Note that thus we add
 * a set of alignments to each pair, so we use the term "corpus" to address not 
 * only the sentence pairs in the database, but also their current n-best
 * alignments.
 * 
 * @see SentencePair
 */
public class Corpus implements Iterable<SentencePair> {
	/*
	 * Stores the set of SentencePairs
	 */
	private List<SentencePair> database;
	
	/**
	 * Sole constructor. Creates an empty corpus.
	 */
	public Corpus() {
		database = new LinkedList<SentencePair>();
	}
	
	/**
	 * Add a new sentence pair to the corpus. If the sentence pair already 
	 * exists in the corpus, add it anyway.
	 * 
	 * @param sentencePair the sentence pair to add
	 */
	public void add(SentencePair sentencePair) {
		database.add(sentencePair);
	}

	/**
	 * Iterator iterates over all sentence pairs in the corpus.
	 * {@inheritDoc}
	 */
	@Override
	public Iterator<SentencePair> iterator() {
		return database.iterator();
	}
	
	/**
	 * Get the number of sentence pairs in the corpus.
	 * 
	 * @return the number of sentence pairs
	 */
	public int size() {
		return database.size();
	}
}
